<template>
    <div>
        <!-- {{ zhi.a }}
        {{ a }} -->
        <hr>
        <!-- {{ list }} -->
        <button @click="addDataList">hooks 的方法</button>
        {{ dataList }}

        <button @click="sedToy(t)"> 发送值给父亲</button>
        <button @click="sedToy3()"> 发送值给父亲:自定义事件</button>


        <button @click="undataHooks()">改变hooks 的值</button>

    </div>
</template>


<script setup lang="ts">



import useListData from '@/hooks/useListData';
import { type person, type p2 } from '@/types/index'
import { defineProps, withDefaults, ref, inject, provide } from 'vue';


// const moneyProvider = inject('money') as { money: number; undata: (value: number) => void };
// const { money, undata } = moneyProvider;

// let emit2 = defineEmits(['sedToy2'])
const emit2 = defineEmits<{
    (event: 'sedToy2', message: string): void;
}>();


function sedToy3() {
    emit2('sedToy2', 'emit2')
}

let t = ref('玩具')
let { dataList, addDataList } = useListData()

function undataHooks(){
    dataList.value=[{
        name:'1',       age: "22"
    }]
}
//接受 父组件的值
// defineProps(['a'])
// 接受  加 限制类型
// let zhi = defineProps<{ list?: p2 }>()

defineProps(['sedToy'])
defineExpose({
    t

})
// let zhi = withDefaults(defineProps<{ list?: p2 }>(), {

//     list: () => [{ name: '1', age: 2 }]
// })
// console.log(zhi);

</script>

<style lang="scss" scoped></style>